﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 玩具商城管理系统
{
    public partial class register : Form
    {
        public register()
        {
            InitializeComponent();
        }

        private void btnok_Click(object sender, EventArgs e)
        {
            this.Hide();
            if (txtName.Text == "" || txtPwd.Text == "")
            {
                MessageBox.Show("用户名或密码不能为空");
            }
            else
            {
                DB.GetCn();
                string str = "select * from client where client_name='"
                    + txtName.Text + "'";
                DataTable dt = DB.GetDataSet(str);
                if (dt.Rows.Count > 0)
                {
                    MessageBox.Show("此用户名已存在，请重新输入");
                }
                else
                {
                    string sdr = "insert client (client_name,client_pwd,client_email,client_power)values('"
                        + txtName.Text + "','" + txtPwd.Text + "','" + txtEmail.Text + "','普通用户')";
                    DB.sqlEx(sdr);
                    MessageBox.Show("注册成功");
                    Form1.flag = 1;
                    this.Close();
                    this.DialogResult = DialogResult.OK;

                }
            }
        }

        private void btnclose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void register_Load(object sender, EventArgs e)
        {
            label7.Parent = label6;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            label7.Top = label6.Height / 2;
            if (label7.Left<-label7.Width)
            {
                label7.Left = label6.Width;
            }
            label7.Left -= 10;
        }
    }
}
